<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ page import="java.util.Collection,org.apache.commons.lang.StringUtils" %>
<%@ page import="com.hz.supermanage.dao.*,com.hz.supermanage.bean.*" %>
<%--<%@page import="com.hz.framework.util.StringCode"%>
--%><%
	request.setCharacterEncoding("UTF-8");
    String key = request.getParameter("key");
	System.out.println(key);
	if(key!=null||!"".equals(key)){
		//StringCode.doStringCode(key);
		//key = new String(key.getBytes("iso-8859-1"),"utf-8");
	}
    //Collection roles = null;
    Collection treeNodes = null;
    OrganizationDao dao= new OrganizationDao();
    boolean bOrgAdmin = true;//XWFSecurity.isOrgAdmin(oaUser);
    try {
        if (StringUtils.isBlank(key)) {
            // throw new BusinessException("关键字不能为空");
        }
        //如果不是单位管理则只能查出在其单位下的单位与其本身
        if (!bOrgAdmin) {
            String orgPath = "";//SecurityMgr.getOrgPath(oaUser);
            treeNodes = dao.queryLikeNodeName(key,orgPath);
        }else{
        	treeNodes = dao.queryLikeNodeName(key,"");
        }
      /*EntityMap emRoles = new QEntityMap(TBLTSysRole.instance);
        emRoles.put(TBLTSysRole.ROLENAME, new EntityCondition(" like '%" + key + "%'"));
        emRoles.put(TBLTSysRole.ROLEID);
        emRoles.put(TBLTSysRole.ACTIVESTATE, Organization.NOT_DELETE);
        dao.list(emRoles);

        roles = emRoles.getCollection();
        for (java.util.Iterator iterator = roles.iterator(); iterator.hasNext();) {
            EntityMap map = (EntityMap) iterator.next();
            //获得这个角色所在的目录
            EntityMap emRoleDir = new QEntityMap(TBLTSysRoleDir.instance);
            emRoleDir.put(TBLTSysRoleDir.ROLEID, map.getJspString(TBLTSysRole.ROLEID));
            emRoleDir.put(TBLTSysRoleDir.ID);
            dao.load(emRoleDir);
            if (emRoleDir.isHasResult()) { //有关联
                map.put("@roleparent", "Role@" + emRoleDir.getJspString(TBLTSysRoleDir.ID));
            }else { //设置到未分类角色当中
                map.put("@roleparent", "Role@unsortrole");
            }
        }*/

    } catch (Exception e) {
    	e.printStackTrace();
    } 
%>
<?xml version="1.0" encoding="UTF-8"?>
<xuice>
    <%
        for (java.util.Iterator iterator = treeNodes.iterator(); iterator.hasNext();) {
        	Hzsysorganization map = (Hzsysorganization) iterator.next();
     %>
     <node type="<%=map.getDeptype()%>" uuid="<%=map.getDepid()+""%>" path="<%=map.getUrl()%>"><![CDATA[<%=map.getDepname()%>]]></node>
    <%
        }
    %>

    <%--<%
        for (java.util.Iterator iterator = roles.iterator(); iterator.hasNext();) {
            EntityMap map = (EntityMap) iterator.next();
%>
<node type="R" uuid="<%=map.getJspString(TBLTSysRole.ROLEID)%>" path="Role@Tree.<%=map.getJspString("@roleparent")%>.Role@@<%=map.getJspString(TBLTSysRole.ROLEID)%>"><![CDATA[<%=map.getJspString(TBLTSysRole.ROLENAME)%>]]></node>    
    <%
        }
    %>
--%></xuice>